<?xml version="1.0" encoding="UTF-8"?>
<!--

       Copyright 2006-2021 the original author or authors.

       Licensed under the Apache License, Version 2.0 (the "License");
       you may not use this file except in compliance with the License.
       You may obtain a copy of the License at

          http://www.apache.org/licenses/LICENSE-2.0

       Unless required by applicable law or agreed to in writing, software
       distributed under the License is distributed on an "AS IS" BASIS,
       WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
       See the License for the specific language governing permissions and
       limitations under the License.

-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Supplied Plugins</title>
  <link rel="stylesheet" type="text/css" href="../mbgstyle.css" />
</head>
<body>
<h1>Supplied Plugins</h1>
<p>As usage of MyBatis Generator (MBG) grows, we find it increasingly
useful to add capabilities through plugins, rather than adding to the complexity
of the base code generators.  Plugins are a modular and easily understood mechanism
for extending MBG.  For more information on writing a plugin, see
<a href="pluggingIn.html">Implementing Plugins</a>.  For information on
configuring plugins, see <a href="../configreference/plugin.html">&lt;plugin&gt;</a></p>

<p>Most of the supplied plugins are in the package
<code>org.mybatis.generator.plugins</code>.  The supplied plugins demonstrate
different types of tasks that can be accomplished with MBG plugins.  Source
code for the plugins is available with the MBG downloads, or can be viewed
online
<a target="_blank" href="https://github.com/mybatis/generator/tree/master/core/mybatis-generator-core/src/main/java/org/mybatis/generator/plugins">
here</a>.</p>

<h2>org.mybatis.generator.plugins.CacheNamespacePlugin</h2>
<p>This plugin adds a @CacheNamespace annotation to generated mapper interface (Kotlin or Java).  This
    plugin is for MyBatis3 targeted runtimes only.</p>
<p>This plugin accepts the following properties.  All are optional and,
    if specified, the values (except "cache_skip") will be passed directly to the corresponding property
    on the generated @CacheNamespace annotation. If "cache_skip" is set to "true" on the plugin configuration,
    or for any table, the annotation will not be generated.</p>
<ul>
    <li>cache_blocking</li>
    <li>cache_flushInterval</li>
    <li>cache_readWrite</li>
    <li>cache_size</li>
    <li>cache_skip</li>
</ul>
<p>Any property can be overridden by specifying the property on a &lt;table&gt; element.</p>

<h2>org.mybatis.generator.plugins.CachePlugin</h2>
<p>This plugin has no impact when the target runtime in use does not generate XML.</p>
<p>This plugin adds a &lt;cache&gt; element to generated SQL maps.</p>
<p>This plugin accepts the following properties.  All are optional and,
if specified, the values will be passed directly to the corresponding property
on the generated &lt;cache&gt; element.</p>
<ul>
  <li>cache_eviction</li>
  <li>cache_flushInterval</li>
  <li>cache_readOnly</li>
  <li>cache_size</li>
  <li>cache_type</li>
</ul>
<p>Any property can be overridden by specifying the property on a &lt;table&gt;
element.</p>

<h2>org.mybatis.generator.plugins.CaseInsensitiveLikePlugin</h2>
<p>This plugin has no impact when the target runtime in use is based on MyBatis Dynamic SQL.</p>
<p>This plugin adds methods to the Example class (actually to the Criteria inner class)
to support case insensitive LIKE searches.  This demonstrates adding functionality to
the example classes via a plugin, rather than extending the class.</p>

<h2>org.mybatis.generator.plugins.EqualsHashCodePlugin</h2>
<p>This plugin has no impact and is not needed when the target runtime in use is MyBatis3Kotlin.</p>
<p>This plugin adds <code>equals</code> and <code>hashCode</code> methods to the
Java model objects generated by MBG.</p>
<p>By default, the <code>equals</code> and <code>hashCode</code> method checks the only fields it knows
about generated by this class.</p>

<p>This plugin accepts one property:</p>
<ul>
    <li><tt>useEqualsHashCodeFromRoot</tt> (optional) If you have specified root class, you can use
        this property to call super <code>equals</code> and <code>hashCode</code> methods for check
        fields of root class. It can be useful for tables with inheritance relation.</li>
</ul>

<h2>org.mybatis.generator.plugins.FluentBuilderMethodsPlugin</h2>
<p>This plugin has no impact and is not needed when the target runtime in use is MyBatis3Kotlin.</p>
<p>This plugin adds fluent builder methods to the generated model classes.</p>

Example:
<ul>
    <li>given the domain class <code>MyDomainClass</code></li>
    <li>with setter-method <code>setFoo(String foo)</code></li>
    <li>with setter-method <code>setBar(Integer bar)</code></li>
</ul>

The plugin will create the additional Methods:
<ul>
    <li><code>public MyDomainClass withFoo(String foo)</code></li>
    <li><code>public MyDomainClass withBar(Integer bar)</code></li>
</ul>

<p>This plugin does not accept any properties.</p>

<p>Using this plugin, you can configure the property values fluently with chained method calls. Example: <code>new MyDomain().withFoo("Test").withBar(4711);</code></p>


<h2>org.mybatis.generator.plugins.MapperAnnotationPlugin</h2>
<p>This plugin has no impact and is not needed when the target runtime in use is based on MyBatis Dynamic SQL.</p>
<p>This plugin adds the <code>@Mapper</code> annotation to generated mapper interfaces.  This
plugin should only be used in MyBatis3 environments.</p>

<h2>org.mybatis.generator.plugins.MapperConfigPlugin</h2>
<p>This plugin has no impact and is not needed when the target runtime in use is based on MyBatis Dynamic SQL.</p>
<p>This plugin generates a skeleton MapperConfig.xml file that contains
references to the XML mapper files generated by MBG.
This file can be used to configure MyBatis 3.x environments.</p>
<p>This plugin accepts three properties:</p>
<ul>
  <li><tt>fileName</tt> (optional) the name of the generated file.
      this defaults to "MapperConfig.xml" if not specified.</li>
  <li><tt>targetPackage</tt> (required) the name of the package where the
      file should be placed.  Specified like "com.mycompany.sql".</li>
  <li><tt>targetProject</tt> (required) the name of the project where the
      file should be placed.</li>
</ul>
<p>Note: <code>targetPackage</code> and <code>targetProject</code> follow
   the same rules as the <code>targetPackage</code> and <code>targetProject</code>
   values on the sqlMapGenerator configuration element.</p>

<h2>org.mybatis.generator.plugins.RenameExampleClassPlugin</h2>
<p>This plugin has no impact and is not needed when the target runtime in use is based on MyBatis Dynamic SQL.</p>
<p>This plugin demonstrates usage of the <code>initialized</code> method
by renaming the generated example classes generated by MBG.</p>
<p>This plugin accepts two properties:</p>
<ul>
  <li><tt>searchString</tt> (required) a regular expression used to search
      the default generated name of the example class.</li>
  <li><tt>replaceString</tt> (required) the string to be inserted on matches of the
      <tt>searchString</tt>.</li>
</ul>
<p>For example, to rename the generated example classes from xxxExample to
   xxxCriteria, specify <tt>Example$</tt> for <tt>searchString</tt>
   and <tt>Criteria</tt> for <tt>replaceString</tt></p>

<h2>org.mybatis.generator.plugins.RowBoundsPlugin</h2>
<p>This plugin has no impact and is not needed when the target runtime in use is based on MyBatis Dynamic SQL.</p>
<p>This plugin will add a new version of the <code>selectByExample</code>
method that accepts a <code>RowBounds</code> parameter.  This supports the
MyBatis RowBounds function where a returned result list can be limited
in length, and a start position can be specified.  This can be useful
in paging applications.</p>
<p>This plugin is only valid for MyBatis3 target runtime.</p>

<h2>org.mybatis.generator.plugins.SerializablePlugin</h2>
<p>This plugin adds the marker interface <code>java.io.Serializable</code> to the
Java model classes, and/or the Kotlin data classes, generated by MBG. For Java, this plugin also adds the
<code>serialVersionUID</code> field to the model classes.</p>
<p>Important: This is a simplistic implementation of java.io.Serializable and does
not attempt to do any versioning of classes.</p>
<p>This plugin accepts two properties. Note that both properties are ignored for Kotlin data classes. For
Kotlin data classes, the plugin will always and only add <code>java.io.Serializable</code>.</p>
<ul>
  <li><tt>addGWTInterface</tt> (optional) True/False.  If true, the plugin will add
      the Google Web Toolkit (GWT) <code>IsSerializable</code> interface to the model
      objects.  The default is false.</li>
  <li><tt>suppressJavaInterface</tt> (required) True/False.  If true, the plugin will
    NOT add the <code>java.io.Serializable</code> interface.  This is for the case where
    the objects should be serializable for GWT, but not in the strict Java sense.  The
    default is false.</li>
</ul>

<h2>org.mybatis.generator.plugins.ToStringPlugin</h2>
<p>This plugin has no impact and is not needed when the target runtime in use is MyBatis3Kotlin.</p>
<p>This plugin adds <code>toString()</code> methods to the generated
model classes.</p>

<p>This plugin accepts one property:</p>
<ul>
    <li><tt>useToStringFromRoot</tt> (optional) If you have specified root class, you can use
        this property to call super <code>toString</code> method for print
        fields of root class. It can be useful for tables with inheritance relation.</li>
</ul>

<h2>org.mybatis.generator.plugins.UnmergeableXmlMappersPlugin</h2>
<p>This plugin has no impact and is not needed when the target runtime in use is based on MyBatis Dynamic SQL.</p>
<p>This plugin will disable the XML merge function for generated mapper XML files.  This
will cause the generator to respect the overwrite flag for XML files in the same way it does
for Java files - if overwrite is true, then an existing file will be overwritten, else a
new file will be written with a unique name.</p>
<p>This plugin can be helpful if you disable all comments.</p>

<h2>org.mybatis.generator.plugins.VirtualPrimaryKeyPlugin</h2>
<p>This plugin can be used to specify columns that act as primary
keys, even if they are not defined as primary key in the database.
This is useful in the case where the database table does not have a
primary defined.  Normally, MBG will generate a very limited
set of methods if there is no primary key.  This plugin can be
used to enable generation of the full compliment of MBG methods.</p>
<p>To use the plugin, add the property "virtualKeyColumns" to your
&lt;table&gt; configuration and set the value to a comma or space
delimited list of column names that should be treated as primary
keys.  The column names must exactly match the column names
returned from the database (typically all UPPERCASE).  For example:</p>
<pre>
  &lt;table tableName="foo"&gt;
    &lt;property name="virtualKeyColumns" value="ID1, ID2" /&gt;
  &lt;/table&gt;
</pre>

</body>
</html>
